package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsCenterIntroduction;
import com.ruoyi.system.domain.news.query.NewsCenterIntroductionQuery;
import com.ruoyi.system.domain.news.vo.NewsCenterIntroductionVo;
import com.ruoyi.system.domain.news.vo.NewsCenterIntroductionVo;
import com.ruoyi.system.mapper.news.NewsCenterIntroductionMapper;
import com.ruoyi.system.service.news.NewsCenterIntroductionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsCenterIntroductionServiceImpl extends ServiceImpl<NewsCenterIntroductionMapper, NewsCenterIntroduction>
        implements NewsCenterIntroductionService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsCenterIntroductionVo> getNewsCenterIntroductionList(NewsCenterIntroductionQuery newsCenterIntroductionQuery) {
        if (newsCenterIntroductionQuery.getIfPage()) {
            PageHelper.startPage(newsCenterIntroductionQuery.getPageNum(), newsCenterIntroductionQuery.getPageSize());
        }
        List<NewsCenterIntroductionVo> newsCenterIntroductionVoList = baseMapper.getNewsCenterIntroductionList(newsCenterIntroductionQuery);
        if (!newsCenterIntroductionVoList.isEmpty() && newsCenterIntroductionQuery.getId() == null) {
            for (NewsCenterIntroductionVo newsCenterIntroductionVo:newsCenterIntroductionVoList) {
                newsCenterIntroductionVo.setContent(null);
            }
        }
        return newsCenterIntroductionVoList;
    }
}
